﻿<!DOCTYPE>
<html ng-app="weChatMain">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, width=device-width, minimal-ui">
    <link href="/css/style.css" rel="stylesheet" type="text/css" />
    <script src="/framework/angular-wang-editor/dist/js/lib/jquery-1.10.2.min.js" type="text/javascript"></script>
	<link rel="stylesheet" type="text/css" href="/css/pensonel.css" />
    <script src="/framework/angular.min.js"></script>
    <title ng-bind="systemTitle"></title>
    <style type="text/css">
    .active{color: #39f; border:1px #39f solid !important;;}
    </style>
</head>

<body style=" background:#fff;"   ng-controller="weChatPayCtrl" ng-cloak>
<!--loading-->
       <div class="jisuloading" style="z-index:10001" ng-if="hasState">
        <div class="img">
            <center>
            <img src="/images/yemianloding.gif" width="90" height="90" />
            </center>
            正在检查扫描结果。。。
        </div>
    </div>

    <script src="/framework/lodash.min.js" type="text/javascript"></script>
    <script src="/framework/restangular/restangular.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="/framework/angular-toastr/angular-toastr.min.js"></script>
    <script type="text/javascript" src="/framework/angular-toastr/angular-toastr.tpls.min.js"></script>
    <script src="/system/service/common.js" type="text/javascript"></script>
    <script type="text/javascript">
        var mainApp = angular.module("weChatMain", ['Common']).config(['$locationProvider',function ($locationProvider) {
            $locationProvider.html5Mode({
                enabled: true,
                requireBase: false//必须配置为false，否则<base href=''>这种格式带base连接的地址才能解析
            });
        } ]);

        mainApp.controller('weChatPayCtrl', ['$scope', 'Restangular', function ($scope, Restangular){

            Restangular.addFullRequestInterceptor(function(element, operation, route, url, headers, params, httpConfig) {     
                return {              
                    headers: {"Content-Type": "application/x-www-form-urlencoded;charset=utf-8"}  
                };
            });
            $scope.QueryString = function (fieldName) {
                /// <summary>
                ///   获得URL GET参数  
                /// </summary>
                /// <param name="fieldName" type="String">
                ///   参数名
                /// </param>
                /// <returns type="void" />如果不存在返回NULL
                var reg = new RegExp("(^|&)" + fieldName.toLowerCase() + "=([^&]*)(&|$)", "i");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]); return null;
            }
            var code = $scope.QueryString("code");
            var url = $scope.QueryString("url");


            Restangular.one("/payment").customPOST({ name: "My Message" }, "getAppId", { code: code }).then(function (retobj) {
                location.href = url + "?code=" + retobj;
             })
        } ]);

    </script>
</body>
</html>
